package com.zhuizikejithreeig.cn.threeigkeji;

import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.zhuizikejithreeig.cn.threeigkeji.loginfo.LoginActivity;
import com.zhuizikejithreeig.cn.weigit.MyVideoView;
import com.zhuizikejithreeig.cn.weigit.OnFinishListener;
import com.zhuizikejithreeig.cn.weigit.ProgressView;

public class SplashActivity extends AppCompatActivity {
    //    private MyVideoView mSplashVidoview;
//    private ProgressView mProgressView;
//    private TextView mTextView;
    private Handler handler = new Handler(Looper.getMainLooper());
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
//        mProgressView = (ProgressView) findViewById(R.id.progressview);
//        mSplashVidoview = (MyVideoView) findViewById(R.id.splash_vidoview);
//        mTextView = (TextView) findViewById(R.id.text);
//        mSplashVidoview.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video));
        //播放
//        mSplashVidoview.start();
        //循环播放
//        mSplashVidoview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
//            @Override
//            public void onCompletion(MediaPlayer mediaPlayer) {
//
//                mSplashVidoview.start();
//
//
//            }
//        });


        //跳过的点击事件
//        mProgressView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                mSplashVidoview.pause();
//                startActivity(new Intent(SplashActivity.this,MainActivity.class));
//                finish();
//            }
//        });

        //设置进度条颜色
//        mProgressView.setPaintColor("#ff0000");
        //开始倒计时
//        mProgressView.startDownTime(2000, new OnFinishListener() {
//            @Override
//            public void onFinish() {
////                mSplashVidoview.pause();
//                startActivity(new Intent(SplashActivity.this, MainActivity.class));
//                finish();
//            }
//        });

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(SplashActivity.this, LoginActivity.class));
                finish();
            }
        }, 2000);


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        mSplashVidoview = null;
//        mProgressView = null;
        handler.removeCallbacksAndMessages(null);
        handler = null;
    }
}
